*** Set working directory ***
cd "C:\..."

*********************** Load Data **********************************************
clear
graph drop _all
cap drop all

use Firm_Level

************************** Setup ***********************************************
sort date

* Merge & Standardize Quarterly MP Shock series
merge m:1 date using fomc_GSW_yields_qtr
drop if _merge != 3
drop _merge
egen mps_std = sd(chg_sveny02)
gen mps = chg_sveny02/mps_std

sort gvkey date
xtset gvkey date

replace invest = invest*100 

***************************** Regressions **************************************
gen gscpi_mps = L.gscpi*mps
gen gscpi_size = L.gscpi*L.size
gen mps_size = mps*L.size
gen gscpi_mps_size = L.gscpi*mps*L.size
gen gscpi_age = L.gscpi*L.age
gen mps_age = mps*L.age
gen gscpi_mps_age = L.gscpi*mps*L.age

****
sort date
by date: egen s50 = pctile(size), p(50)
by date: egen a50 = pctile(age), p(50)
sort gvkey date
xtset gvkey date

reghdfe invest mps L.gscpi gscpi_mps L.current L.salesg L.size L.ptoc L.rmptos L.dtoa L.age L.cap L.levg L.lqdty, absorb(gvkey) cluster(gvkey)
outreg2 using "table4.xml", replace se bdec(3) bracket label  
reghdfe invest mps L.gscpi gscpi_mps L.current L.salesg L.size L.ptoc L.rmptos L.dtoa L.age L.cap L.levg L.lqdty if age < a50, absorb(gvkey) cluster(gvkey)
outreg2 using "table4.xml", append se bdec(3) bracket label  
reghdfe invest mps L.gscpi gscpi_mps L.current L.salesg L.size L.ptoc L.rmptos L.dtoa L.age L.cap L.levg L.lqdty if age >= a50, absorb(gvkey) cluster(gvkey)
outreg2 using "table4.xml", append se bdec(3) bracket label  
reghdfe invest mps L.gscpi gscpi_mps L.current L.salesg L.size L.ptoc L.rmptos L.dtoa L.age L.cap L.levg L.lqdty if size < s50, absorb(gvkey) cluster(gvkey)
outreg2 using "table4.xml", append se bdec(3) bracket label  
reghdfe invest mps L.gscpi gscpi_mps L.current L.salesg L.size L.ptoc L.rmptos L.dtoa L.age L.cap L.levg L.lqdty if size >= s50, absorb(gvkey) cluster(gvkey)
outreg2 using "table4.xml", append se bdec(3) bracket label  


********************************************************************************